package com.weixing.mall.provider.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weixing.mall.base.enums.WhetherEnum;
import com.weixing.mall.provider.mapper.LeaveMessageMapper;
import com.weixing.mall.provider.model.domain.LeaveMessage;
import com.weixing.mall.provider.model.dto.LeaveMessageReplyDto;
import com.weixing.mall.provider.model.query.LeaveMessageQuery;
import com.weixing.mall.provider.model.vo.LeaveMessagePersonVo;
import com.weixing.mall.provider.model.vo.LeaveMessageVo;
import com.weixing.mall.provider.service.ILeaveMessageService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 会员模块-留言表 服务实现类
 * </p>
 *
 * @author Small
 * @since 2019-11-13
 */
@Service
public class LeaveMessageServiceImpl extends ServiceImpl<LeaveMessageMapper, LeaveMessage> implements ILeaveMessageService {

    @Override
    public IPage<LeaveMessagePersonVo> selectByMemberId(Page page, Long mid) {
        return baseMapper.selectByMemberId(page,mid);
    }


    @Override
    public IPage<LeaveMessageVo> selectList(Page page, LeaveMessageQuery leaveMessageQuery) {
        return baseMapper.selectVoList(page,leaveMessageQuery);
    }

    @Override
    public void reply(LeaveMessageReplyDto leaveMessageReplyDto) {
        LeaveMessage leaveMessage = new LeaveMessage();
        BeanUtils.copyProperties(leaveMessageReplyDto,leaveMessage);
        leaveMessage.setReplyTime(new Date());
        leaveMessage.setIsReply(WhetherEnum.YES.getValue());
        updateById(leaveMessage);
    }

    @Override
    public LeaveMessageVo selectDetail(long id) {
        return baseMapper.selectDetail(id);
    }
}
